// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie;

import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@XmlRootElement
public final class FileGuidTable {
    public final ArrayList<zombie.FileGuidPair> files = new ArrayList();
    @XmlTransient
    private final Map<String, String> guidToPath = new TreeMap(String.CASE_INSENSITIVE_ORDER);
    @XmlTransient
    private final Map<String, String> pathToGuid = new TreeMap(String.CASE_INSENSITIVE_ORDER);

    public void setModID(String modID) {
        for (zombie.FileGuidPair fileGuidPair : this.files) {
            fileGuidPair.guid = modID + "-" + fileGuidPair.guid;
        }
    }

    public void mergeFrom(zombie.FileGuidTable other) {
        this.files.addAll(other.files);
    }

    public void loaded() {
        for (zombie.FileGuidPair fileGuidPair : this.files) {
            this.guidToPath.put(fileGuidPair.guid, fileGuidPair.path);
            this.pathToGuid.put(fileGuidPair.path, fileGuidPair.guid);
        }
    }

    public void clear() {
        this.files.clear();
        this.guidToPath.clear();
        this.pathToGuid.clear();
    }

    public String getFilePathFromGuid(String guid) {
        return (String)this.guidToPath.get(guid);
    }

    public String getGuidFromFilePath(String path) {
        return (String)this.pathToGuid.get(path);
    }
}
